package kos.robert.loader;

import kos.robert.screens.Screen;
import java.awt.*;
import javax.swing.ImageIcon;
import javax.swing.ImageIcon;
import javax.swing.JFrame;

public class Images extends JFrame {

	public static void main(String[] args) {
		DisplayMode dm = new DisplayMode(1024, 768, 32, DisplayMode.REFRESH_RATE_UNKNOWN);
		Images i = new Images();
		i.run(dm);
	}

	private Screen s;
	private Image bg, pic;
	private boolean loaded;

	// run method
	public void run(DisplayMode dm) {
		setBackground(Color.BLACK);
		setForeground(Color.BLACK);
		setFont(new Font("Arial", Font.PLAIN, 24));
		loaded = false;

		s = new Screen();
		try {
			s.setFullScreen(null, this);
			loadpics();
			try {
				Thread.sleep(5000);
			} catch (Exception e) {
				// System.out.println("GameWindow has been interrupted\n");
			}
		} finally {
			s.restoreScreen();
		}
	}

	// load pictures
	public void loadpics() {
		bg = new ImageIcon("resources/graphics/back.png").getImage();
		pic = new ImageIcon("resources/graphics/face.png").getImage();
		loaded = true;
		repaint();
	}

	public void paint(Graphics g) {
		if (g instanceof Graphics2D) {
			Graphics2D g2 = (Graphics2D) g;
			g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
		}
		if (loaded) {
			g.drawImage(bg, 0, 0, null);
			g.drawImage(pic, 100, 100, 20, 20, null);
			g.drawImage(pic, 200,200,400,400, 0, 0, 200, 200,null);
			g.drawRect(199, 199, 201, 201);
		}

	}
}